package com.cjh.springcloud.service;

import com.cjh.springcloud.pojo.Emp;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author cjh
 * @Date 2020/12/11 9:26
 * @Version 1.0
 * hystrix服务降级
 */
@Component
public class EmpClientServiceFallBackFactory implements FallbackFactory {
    public EmpClientService create(Throwable throwable) {
        return new EmpClientService() {
            public Emp getById(Integer empId) {
                return new Emp().setEmpId(empId)
                        .setEmpName("empId=>" + empId + "，没有对应的信息，提供了降级信息，这个服务已被关闭。");
            }

            public List<Emp> getAll() {
                return null;
            }
        };
    }
}
